
NG.command.ShortestPath = function(params) {
	
	function createGeometryMember() {
		return {
			geometryMember: {
				Point: {
					coordinates: ''
				}
			}			
		};
	}

	this.NetworkName = '';
	this.NETCAD_GML = {
		/**
		 * array of geometryMember object
		 */
		MultiGeometry: []
	};
	
};

/**
 * 
 * @class NG.command.ShortestFind
 * @extends Ext.util.Observable
 */
NG.command.ShortestFind = Ext.extend(NG.command.Request, {
	
	/**
	 * {NG.models.NetworkInfo}
	 */
	networkInfo:null,
	
	/**
	 * OpenLayers.Geometry.Point
	 */
	startPoint:null,
	
	/**
	 * OpenLayers.Geometry.Point
	 */
	finishPoint:null,
	
	constructor: function(config){
		config = config || {};
		config.serviceName = XSN_NETWORK_SHORTEST_FIND;
		NG.command.ShortestFind.superclass.constructor.call(this, config);
		//this.networkInfo = config.networkInfo;
		this.validate();
	},

	/**
	 * 
	 * @returns xml data
	 */
	getDataXML: function(){
		/*
		 *<ShortestPath>
	<NetworkName>BAGLANTI1.YOL.NCSPATIAL</NetworkName>
	<NETCAD_GML>
		<MultiGeometry>
			<geometryMember>
				<Point>
					<coordinates>443030.972502165,4530166.31175154,0.00000000</coordinates>
				</Point>
			</geometryMember>
			<geometryMember>
				<Point>
					<coordinates>443838.422008603,4529936.78454854,0.00000000</coordinates>
				</Point>
			</geometryMember>
		</MultiGeometry>
	</NETCAD_GML>
</ShortestPath> 
		 * */
		var startPointCoordinates = this.startPoint.x + "," + this.startPoint.y + ",0.00000000";
		var finishPointCoordinates = this.finishPoint.x + "," + this.finishPoint.y + ",0.00000000";
    	var XML = new XMLWriter();
    	XML.BeginNode("ShortestPath");
    		XML.Node("NetworkName", this.networkInfo.getNetwork().getNetworkName());
    		XML.BeginNode("NETCAD_GML");
    			XML.BeginNode("MultiGeometry");
	    			XML.BeginNode("geometryMember");
		    			XML.BeginNode("Point");
		    				XML.Node("coordinates", startPointCoordinates);
		    			XML.EndNode();
	    			XML.EndNode();
	    			XML.BeginNode("geometryMember");
	    			XML.BeginNode("Point");
	    				XML.Node("coordinates", finishPointCoordinates);
	    			XML.EndNode();
    			XML.EndNode();
    		XML.EndNode();
    	XML.EndNode();
    	XML.Close();
    	return XML.ToString();		
	},
	
	validate: function () {
		if (Ext.isEmpty(this.networkInfo))
			throw "netwotkInfo set edilmeli";
		if (Ext.isEmpty(this.startPoint))
			throw "startPoint set edilmeli";
		if (Ext.isEmpty(this.finishPoint))
			throw "finishPoint set edilmeli";
	},
	
	getResponse: function(xmlData){
		return new NG.response.ShortestFind({
			xmlData: xmlData
		});			
	}
});